import {createStore} from 'vuex'
export default createStore({
    state:{
        isCollapse:true,
        currentMenu:null,
        tabsList: [
            {
              path: '/page1',
              name: 'page1',
              label: '学年管理',
              icon: 'page1'
            }
          ],
    },
    mutations:{
        updateIsCollapse(state,payload){
            state.isCollapse = !state.isCollapse
        },
        selectMenu(state,val){
            //判断
            // val.name == 'home' ? (state.currentMenu = null) : (state.currentMenu = val)
        
            if(val.name == 'page1'){
                state.currentMenu = null
            } else{
                state.currentMenu = val
                let result = state.tabsList.findIndex(item => item.name === val.name)
                result == -1 ? state.tabsList.push(val) : ''
            }
        },
        closeTab(state, val) {
            let res = state.tabsList.findIndex(item => item.name === val.name)
            state.tabsList.splice(res, 1)

        },
    }
})